import { useState, useEffect, useLayoutEffect } from "react";

const Counter = () => {
    const [count, setCount] = useState(0);
    let timer = null;
    useLayoutEffect(() => {
        console.log("useLayoutEffect");
    }, []);
    useEffect(() => {
        console.log("useEffect");
        timer = setInterval(() => {
            setCount((count) => count + 4);
        }, 1000);
        return () => clearInterval(timer);
    }, []);
    return <div className='alert alert-danger'>当前count的值为：{count}</div>;
};

export default Counter;
